<template>
  <v-snackbar v-model="show" :timeout="timeout" top :color="color" class="pt-8" outlined>
    {{ message }}
    <template v-slot:action>
      <v-btn :color="color" icon @click="show=false">
        <v-icon small>mdi-close</v-icon>
      </v-btn>
    </template>
  </v-snackbar>
</template>
<script>
  export default {
    name: 'model-loading',
    data() {
      return {
        show: false,
        message: '',
        timeout: -1,
        color: 'black',
      }
    },
    onNoticed({ flag, message = '', color = 'black', timeout = -1 }) {
      if (flag) {
        this.message = message
        this.color = color || 'black'
        if (timeout > 0) this.timeout = Math.min(3000, timeout)
      }
      this.show = flag
    },
  }
</script>